#ifndef _JSONRPC_H_
#define _JSONRPC_H_
//
// JsonRpc++ Copyright (c) 2007 by Peter Wang
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
// 

#if defined(_MSC_VER)
# pragma warning(disable:4786)    // identifier was truncated in debug info
#endif

#ifndef MAKEDEPEND
# include <string>
#endif

#include "JsonRpcClient.h"
#include "JsonRpcException.h"
#include "JsonRpcServer.h"
#include "JsonRpcServerMethod.h"
#include "JsonRpcUtil.h"

namespace JsonRpc {


  //! An interface allowing custom handling of error message reporting.
  class JsonRpcErrorHandler {
  public:
    //! Returns a pointer to the currently installed error handling object.
    static JsonRpcErrorHandler* getErrorHandler() 
    { return _errorHandler; }

    //! Specifies the error handler.
    static void setErrorHandler(JsonRpcErrorHandler* eh)
    { _errorHandler = eh; }

    //! Report an error. Custom error handlers should define this method.
    virtual void error(const char* msg) = 0;

  protected:
    static JsonRpcErrorHandler* _errorHandler;
  };

  //! An interface allowing custom handling of informational message reporting.
  class JsonRpcLogHandler {
  public:
    //! Returns a pointer to the currently installed message reporting object.
    static JsonRpcLogHandler* getLogHandler() 
    { return _logHandler; }

    //! Specifies the message handler.
    static void setLogHandler(JsonRpcLogHandler* lh)
    { _logHandler = lh; }

    //! Returns the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
    static int getVerbosity() 
    {
		int iTmp = GetPrivateProfileIntA("Log", "Level", -1, "LogLevel.ini");
		if(iTmp == -1)
			iTmp = _verbosity; 
		return iTmp;
	}

    //! Specify the level of verbosity of informational messages. 0 is no output, 5 is very verbose.
    static void setVerbosity(int v) 
    { _verbosity = v; }

    //! Output a message. Custom error handlers should define this method.
    virtual void log(int level, const char* msg) = 0;
	virtual void log(int level, const char *buf, int len) = 0;

  protected:
    static JsonRpcLogHandler* _logHandler;
    static int _verbosity;
  };

  //! Returns log message verbosity. This is short for JsonRpcLogHandler::getVerbosity()
  int getVerbosity();
  //! Sets log message verbosity. This is short for JsonRpcLogHandler::setVerbosity(level)
  void setVerbosity(int level);


  //! Version identifier
  extern const char JSONRPC_VERSION[];

} // namespace JsonRpc

#endif // _JSONRPC_H_
